import { http } from "@/utils/http";

export type commonResult<T> = {
  code: number;
  msg: string;
  result: T;
};

export type infoType = {
  family?:any,
  familyName:any,
  unityId: any,
  ids: any[],
  serveTime: any,
  noticeStatus: any,
  userId: any,
  familyId: any,
  productId: any,
  modelId: any,
  flowCardId: any,
  roomId: any,
  roomName: any
  deviceSN: any,
  deviceName: any,
  id?: number,
  unityName?: string,
  SN?: string,
  productName?: string,
  deviceId?: number,
  status?: number,
  flowCardNum?: string,
  projectName?: string,
  expireDate?: string,
  room?: {
    roomId?: number,
    roomName?: string
  }
}
export type infoTypeList = {
  data: infoType[];
  total: number;
};

const List = '/system/personal/device/v2/devices';
const Url = '/system/personal/device/v2/device';
export const getList = (params?: object) => {
  return http.request<commonResult<infoTypeList>>("get", List, {
    params
  });
};
export const getInfo = (params?: object) => {
  return http.request<commonResult<infoType>>("get", Url, {
    params
  });
};
export const addInfo = (data?: object) => {
  return http.request<commonResult<any>>("post", Url, {
    data
  });
};
export const editInfo = (data?: object) => {
  return http.request<commonResult<any>>("put", Url, {
    data
  });
};
export const deleteInfo = (data?: object) => {
  return http.request<commonResult<any>>("delete", Url, {
    data
  });
};

/**
 * 1.10.1.9输入序列号获取产品类型信息
 */

export const getProductInfo = (params?: object) => {
  return http.request<commonResult<any>>("get", '/system/personal/device/v2/product-info', {
    params
  });
};

/**
 * 1.10.1.11输入流量卡号获取流量卡id
 */

export const getProductFlow = (params?: object) => {
  return http.request<commonResult<any>>("get", '/system/personal/device/v2/flow', {
    params
  });
};

/**
 * 1.10.1.5服务续费的设备列表
 */

export const getseverList = (params?: object) => {
  return http.request<commonResult<any>>("get", '/system/personal/device/v2/list', {
    params
  });
};

/**
 * 1.10.1.6个体设备服务续费
 */

export const getseverrenew = (data?: object) => {
  return http.request<commonResult<any>>("post", '/system/personal/device/v2/renew', {
    data
  });
};

/** 1.10.1.12下载导入模板 */
export const download = (params?: object) => {
  return http.request<Blob>("get", '/system/personal/device/v2/down-load', {
    params,
     responseType: 'blob'
  });
};

/** 1.10.1.2导入设备 */
export const importDevice = (data?: object) => {
  return http.request<commonResult<any>>("post", '/system/personal/device/v2/import', {
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}
